﻿using System;
using System.Windows;
using Dsl.Ped.Framework.Common;

namespace Dsl.Ped.Framework.Projections.TextProjections
{
    /// <summary>
    /// Hint of the text-based projections
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class TextProjectionHint<T> : ProjectionHint<T>, ITextProjectionHint<T>
        where T : FrameworkElement, new()
    {
        #region Members

        /// <summary>
        /// Gets the type of the projection
        /// </summary>
        public Type ProjectionType
        {
            get { return typeof(T); }
        }

        /// <summary>
        /// Gets or sets a converter that converts an object into the string representation
        /// </summary>
        public Func<Object, string> ToStringConverter { get; private set; }

        /// <summary>
        /// Gets or sets the <see cref="DependencyProperty"/> which the object is bound to and which
        /// displayes something in a text form
        /// </summary>
        public DependencyProperty TextProperty { get; private set; }

        #endregion

        /// <summary>
        /// Initializes a new instance of the <see cref="TextProjectionHint{T}"/> class.
        /// </summary>
        /// <param name="valueProperty">The <see cref="DependencyProperty"/> to which the value is bound</param>
        /// <param name="defaultConfiguration">The default configuration applied to the instance of a projection</param>
        /// <param name="customConfiguration">The custom configuration applied after the <see cref="defaultConfiguration"/></param>
        /// <param name="toStringConverter">The to string converter that converts bound value into a string</param>
        public TextProjectionHint(DependencyProperty valueProperty, Action<T, Type> defaultConfiguration, Action<T> customConfiguration, Func<object, string> toStringConverter)
            : base(defaultConfiguration, customConfiguration)
        {
            this.TextProperty = valueProperty;
            this.ToStringConverter = toStringConverter;
        }
    }
}
